<div id="c_left" style="width: 99%;">
    <div id="info"></div>
    <div class="box-white" style="padding: 0 10px;">
        Danh sách tin tức
        <div style="float: right;">
            <a href="<?=base_url()?>news/addnews">Thêm mới tin</a>
        </div>
    </div>
    <div class="box-content">
    <table>
        <tr>
            <td>
            <select name="option">
                <option value="0">Chọn thao tác</option>
                <option value="1">Xóa</option>
            </select>
            <input type="submit" name="submit" value="Thực hiện">
            </td>
            <td>
                <select name="view" onchange="window.open(this.options[this.selectedIndex].value,'_self'); id_cat.options[0].selected=true">
                    <option value="<?=base_url()?>news/listpub/0">Tất cả chuyên mục</option>
                    <?foreach($postcat as $val):?>
                    <option value="<?=base_url()?>news/listpub/<?=$val->catid?>" <?if($val->catid==$this->uri->segment(3)){echo 'selected="selected"';}?>><?=$val->cat_name?></option> 
                    <?endforeach;?>
                </select>
            </td>
        </tr>
    </table>
    
    <table class="admindata">
        <thead>
            <tr>
                <th style="width: 20px;"><input type="checkbox"></th>
                <th>Tiêu đề</th>
                <th>Alias</th>
                <th>Danh mục</th>
                <th>Ngày</th>
                <th style="width: 50px;">Hiển thị</th>
                <th style="width: 70px;">Lượt xem</th>
                <th>Nguồn</th>
            </tr>
        </thead>
        <tbody id="admindata">
        <?
        $k=1;

        foreach($list as $rs):
        ?>
        <tr class="row<?=$k?> record">
           <td><input type="checkbox"></td>
           <td>
                <?=$rs->post_title?>
                <div class="row_action">
                    <span><a href="<?=base_url()?>news/updatenews/<?=$rs->postid?>/<?=(int)$this->uri->segment(3)?>" >Sửa</a>|</span>
                    <span><a href="#" class="delbutton" id="<?=$rs->postid?>">Xóa</a></span>
                </div>           
           </td>
           <td><?=$rs->post_alias?></td>
           <td><?=$this->news->LoadItemCat($rs->catid)->cat_name?></td>
           <td><?=date('H:i:s d-m-y',$rs->post_dateline)?></td>
           <td align="center" id="publish<?=$rs->postid?>"><?=$this->icon_library->publish("'post'","'postid'",$rs->postid,$rs->publish)?></td>
           <td><?=$rs->post_view?></td>
           <td><?=$rs->tacgia?></td>
        </tr>
        <?
        $k=1-$k;

        endforeach;?>
        </tbody>
    </table>
    <div class="pages"><?=$pagination?></div>
    </div>
</div>
<script type="text/javascript">
$(function() {
$(".delbutton").click(function(){
var element = $(this);
var del_id = element.attr("id");
var info =del_id;
    if(confirm("Bạn có chắc chắn muốn xóa không?"))
    {
        $.ajax({
        type: "POST",
        url: "<?=base_url()?>news/delpub/"+info,
        data: info,   
        success: function(){    
        } 
        });    
        $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
        .animate({ opacity: "hide" }, "slow");

     }
    return false;
});
});
</script>
